/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.com.sml.SEFM.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.support.PagedListHolder;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.SimpleFormController;
import vn.com.sml.SEFM.BUS.fraudStandardBUS;
import vn.com.sml.SEFM.domain.Fraudstandard;

/*
 *
 * @author Tunp
 */
public class ListFraudStandardController extends SimpleFormController implements Controller {
    fraudStandardBUS fraudstandardBUS = new fraudStandardBUS();

    public void setFraudstandardBUS(fraudStandardBUS fraudstandardBUS) {
        this.fraudstandardBUS = fraudstandardBUS;
    }
    
    public ListFraudStandardController() {
        
    }
    
    @Override
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
 
                String id = (arg0.getParameter("userId"));
                          
                if(id==null){
                    List<Fraudstandard> lstFs = null;
                    lstFs = fraudstandardBUS.listfraudStandards();
                                      
                    ModelAndView modelAndView = new ModelAndView("ListFraudStandard");
                    modelAndView.addObject("lstFs", lstFs);
                    
                    return modelAndView;
                }
                else {
                    int fId = Integer.parseInt(id);
                    
                    ModelAndView mv = new ModelAndView("DetailFraudStandard");
                    Fraudstandard fs = fraudstandardBUS.getFraudStandardById(fId);
                    mv.addObject("fraudStandard",fs);
                    
                    return mv;
                }
	}

//     @Override
//    protected void doSubmitAction(Object command) throws Exception {
//        throw new UnsupportedOperationException("Not yet implemented");
//    }

    //Use onSubmit instead of doSubmitAction 
    //when you need access to the Request, Response, or BindException objects
    /*
    @Override
    protected ModelAndView onSubmit(
    HttpServletRequest request, 
    HttpServletResponse response, 
    Object command, 
    BindException errors) throws Exception {
    ModelAndView mv = new ModelAndView("DetailUser");
    //Do something...

    
    return mv;
    }
     */
}

